<template>
  <div v-loading="loading" class="app-container">
    <el-button type="primary" plain style="margin-bottom:10px" @click="back">返回</el-button>
    <el-form :model="queryParams" ref="queryForm" :inline="true" class="search-form-new" label-width="80px" v-if="!hideSearchbar">
      <el-form-item label="店铺" prop="tenantId" v-hasPermi="['searchTenantID']">
        <el-select v-model="queryParams.tenantId" placeholder="请选择店铺" clearable filterable>
          <el-option v-for="dict in tenantList" :key="dict.tenantId" :label="dict.tenantName" :value="dict.tenantId" />
        </el-select>
      </el-form-item>
      <el-form-item label="监控类型" prop="monitorTaskType">
        <el-select clearable v-model="queryParams.monitorTaskType">
          <el-option :label="item.label" :value="key" v-for="(item,key) in taskTypeOptions" :key="key"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="QQ账号" prop="qq">
        <el-input v-model="queryParams.qq" placeholder="请输入" clearable />
      </el-form-item>
      <el-form-item label="商品编号" prop="goodsId">
        <el-input v-model="queryParams.goodsId" placeholder="请输入" clearable />
      </el-form-item>
      <el-form-item class="btns">
        <el-button type="primary" icon="el-icon-search" @click="search">搜索</el-button>
        <el-button icon="el-icon-refresh" type="warning" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>
    <div class="table_box">
      <el-table stripe :data="tableData.records" style="width: 100%">
        <el-table-column label="ID" width="80">
          <template slot-scope="scope">
            <span>{{ scope.row.id }}</span>
          </template>
        </el-table-column>
        <el-table-column label="所属店铺" prop="tenantName" />
        <el-table-column label="监控类型">
          <template slot-scope="scope">
            <el-tag :type="taskTypeOptions[scope.row.monitorTaskType].type">{{ taskTypeOptions[scope.row.monitorTaskType].label  }}</el-tag>
          </template>
        </el-table-column>
        <el-table-column label="状态" prop="remark">
          <template slot-scope="scope">
            <div>
              <el-tag type="danger" v-if="scope.row.taskStatus==0">待执行</el-tag>
              <el-tag type="success" v-if="scope.row.taskStatus==2">已完成</el-tag>
            </div>
          </template>
        </el-table-column>
        <el-table-column label="游戏名称" prop="gameName" />
        <el-table-column label="商品编号" prop="goodsId" />
        <el-table-column label="QQ账号" prop="qq" />
        <el-table-column label="手机号" prop="telephone" width="120" />
        <el-table-column label="账号状态" prop="status">
          <template slot-scope="scope">
            <span v-show="scope.row.status == '0'" style="color: rgb(64, 206, 7)">正常</span>
            <span v-show="scope.row.status == '1'" style="color: red">被找回</span>
            <span v-show="scope.row.status == '2'" style="color: orange">二变无</span>
            <span v-show="scope.row.status == '3'" style="color: rgb(255, 81, 0)">今日上限</span>
            <span v-show="scope.row.status == '4'" style="color: red">账号错误</span>
          </template>
        </el-table-column>

        <el-table-column label="查询结果" prop="bindTel" />
        <el-table-column label="查询时间" prop="createTime" width="160" />
        <el-table-column label="检查完成时间" prop="taskCompleteTime" width="160" />
        <el-table-column label="备注" prop="remark" />

        <!-- remark -->

      </el-table>
      <div class="pages-box">
        <pagination v-show="tableData.total > 0" :total="tableData.total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList" />
      </div>
    </div>

  </div>
</template>
<script>
import checkPhoneApi from "@/api/gameConfig/checkPhonePx";
export default {
  name: "",
  data() {
    return {
      loading: false,
      tableData: {
        records: [],
        total: 0,
      },
      taskTypeOptions: {
        1: {
          label: "掉绑监控",
          value: "1",
          type: "success",
        },
        2: {
          label: "转手监控",
          value: "2",
          type: "danger",
        },
      },
      queryParams: {
        pageNum: 1,
        pageSize: 20,
        goodsId: "",
        accountNumber: "",
        monitorTaskType: "",
      },
      hideSearchbar: false,
    };
  },
  props: ["goodsId"],
  watch: {
    goodsId: {
      handler(val) {
        if (val) {
          this.hideSearchbar = true;
          this.queryParams.goodsId = val;
          this.queryParams.pageNum = 1;
          this.getList();
        }
      },
      immediate: true,
    },
  },
  created() {
    this.getList();
  },
  computed: {
    tenantList() {
      return this.$store.getters.tenantList
    }
  },
  methods: {
    // 返回
    back(){
      window.history.go(-1)
    },
    // 获取列表
    getList() {
      this.tableData.records = [];
      this.loading = true;
      checkPhoneApi
        .monitorTaskRecordlist(this.queryParams)
        .then((response) => {
          this.loading = false;
          this.tableData.records = response.rows;
          this.tableData.total = response.total;
        })
        .catch((err) => {
          this.loading = false;
        });
    },
    search() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    resetQuery() {
      this.queryParams = {
        pageNum: 1,
        pageSize: 20,
        goodsId: "",
        accountNumber: "",
        monitorTaskType: "",
      };
      this.getList();
    },
    close() {
      this.dialogVisible = false;
    },
  },
};
</script>
<style scoped lang="css">
</style>
